package com.sky.mapper;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * @author 符健清
 * @version 1.0
 */
@SuppressWarnings({"all"})
@Mapper
public interface UserShopCarServiceMapper {
    /**
     * 添加购物车
     * @param shoppingCart
     */
    List<ShoppingCart> selectShoppingBy(ShoppingCart shoppingCart);
    /**
     * 清空购物车
     */
    @Delete("delete from shopping_cart where user_id=#{userId} " )
    void deleteAllShoppingCar(ShoppingCart shoppingCart);

    /**
     *
     * @param shoppingCart
     */
    @Insert("insert into  shopping_cart (id, name, image, user_id, dish_id, setmeal_id, dish_flavor, amount, create_time) " +
            "    values (null,#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{amount},#{createTime})")
    void insertShoppingCart(ShoppingCart shoppingCart);

    /**
     * 查看购物车
     * @return
     */
    @Select("select * from shopping_cart  where user_id =#{userId}")
    List<ShoppingCart> selectShopping(Long userId);

    /**
     * number  数量 变化
     * @param shoppingCart
     */
    void updateShoppingCartNumber(ShoppingCart shoppingCart);

    /**
     * 删除一条记录
     * @param shoppingCart
     */
    void deleteShoppingCartOne(ShoppingCart shoppingCart);
}
